const cloneDeep1 = (target, hash = new WeakMap()) => {
	// 对于传入参数处理
	if (typeof target !== 'object' || target === null) {
		return target;
	}
	// 哈希表中存在直接返回
	if (hash.has(target)) return hash.get(target);

	const cloneTarget = Array.isArray(target) ? [] : {};
	hash.set(target, cloneTarget);

	// 针对Symbol属性
	const symKeys = Object.getOwnPropertySymbols(target);
	if (symKeys.length) {
		symKeys.forEach((symKey) => {
			if (typeof target[symKey] === 'object' && target[symKey] !== null) {
				cloneTarget[symKey] = cloneDeep1(target[symKey]);
			} else {
				cloneTarget[symKey] = target[symKey];
			}
		});
	}

	for (const i in target) {
		if (Object.prototype.hasOwnProperty.call(target, i)) {
			cloneTarget[i] =
				typeof target[i] === 'object' && target[i] !== null ? cloneDeep1(target[i], hash) : target[i];
		}
	}
	return cloneTarget;
};

const cloneDeep2 = (target, hash = new WeakMap()) => {
	// 对于传入参数处理
	if (typeof target !== 'object' || target === null) {
		return target; 
	}
	// 哈希表中存在直接返回
	if (hash.has(target)) return hash.get(target);

	const cloneTarget = Array.isArray(target) ? [] : {};
	hash.set(target, cloneTarget);

	// 针对Symbol属性
	const symKeys = Reflect.ownKeys(target);
	symKeys.forEach((symKey) => {
		if (typeof target[symKey] === 'object' && target[symKey] !== null) {
			cloneTarget[symKey] = cloneDeep2(target[symKey], hash);
		} else {
			cloneTarget[symKey] = target[symKey];
		}
	});
	return cloneTarget;
};

var myObject = {
	foo: 1,
	bar: 2,
	good: [1,2,3],
	abin: {
		go: 1212
	},
	[Symbol.for('baz')]: 3,
	[Symbol.for('bing')]: 4
};

var object2 = [2,3,5]

console.log(cloneDeep2(myObject));
console.log(cloneDeep2(object2));
